
**************************************************************************
*** Table 2: Tasks and the Gender Wage Gap (Baseline) 
**************************************************************************
version 17.0
clear all
set more off

global data "D:\DIGITAL ECONOMY\GWG\DATA" 
global output "D:\DIGITAL ECONOMY\GWG\Results" 

use "D:\DIGITAL ECONOMY\GWG\DATA\NRTI.dta" 

global X  "experience experience2 edu_years health marry hukou"
global FE "i.province i.year"
global Z  "reg_unemp_rate hh_nonearn_income"

* OLS
reg ln_monthly_wage_pre Girl NRTI c.NRTI#i.Girl $X $FE , vce(robust)
outreg2 using "Table2.xls", excel replace ///
    adjr2 se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("OLS: All")		
	
reg ln_monthly_wage_pre NRTI  $X $FE if Girl==0 , vce(robust)		
outreg2 using "Table2.xls", excel append ///
    adjr2 se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("OLS: Male") 
 
reg ln_monthly_wage_pre NRTI  $X $FE if Girl==1 , vce(robust)
outreg2 using "Table2.xls", excel append ///
    adjr2 se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("OLS: Female") 

* Heckman (two-step)
heckman ln_monthly_wage_pre Girl NRTI c.NRTI#i.Girl $X $FE , ///
    select(worked = $Z) two
local chi2 = e(chi2)
local df   = e(df_m)
local pval = chi2tail(`df', `chi2')
local chi2_f = string(`chi2', "%9.2f")
local pval_f = string(`pval', "%9.3f")
outreg2 using "Table2.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: All") ///
    addtext("Wald chi2", "`chi2_f'", ///
            "df", "`df'", ///
            "Prob > chi2", "`pval_f'")		
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==0, ///
    select(worked = $Z) two
local chi2 = e(chi2)
local df   = e(df_m)
local pval = chi2tail(`df', `chi2')
local chi2_f = string(`chi2', "%9.2f")
local pval_f = string(`pval', "%9.3f")
outreg2 using "Table2.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Male") ///
    addtext("Wald chi2", "`chi2_f'", ///
            "df", "`df'", ///
            "Prob > chi2", "`pval_f'")
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==1, ///
    select(worked = $Z) two
local chi2 = e(chi2)
local df   = e(df_m)
local pval = chi2tail(`df', `chi2')
local chi2_f = string(`chi2', "%9.2f")
local pval_f = string(`pval', "%9.3f")
outreg2 using "Table2.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Female") ///
    addtext("Wald chi2", "`chi2_f'", ///
            "df", "`df'", ///
            "Prob > chi2", "`pval_f'")
 

**************************************************************************
*** Table 3:  Robustness check
**************************************************************************
 
* Yearly wage
heckman ln_yearly_wage_pre Girl NRTI c.NRTI#i.Girl $X $FE , ///
    select(worked = $Z) two
outreg2 using "Table3.xls", excel replace ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: All ln(yearly wages)")  
		
heckman ln_yearly_wage_pre NRTI $X $FE if Girl==0, ///
    select(worked = $Z) two
outreg2 using "Table3.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Male ln(yearly wages)") 
		
heckman ln_yearly_wage_pre NRTI $X $FE if Girl==1, ///
    select(worked = $Z) two
outreg2 using "Table3.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Female ln(yearly wages)") 
 
* Daily wage
heckman ln_daily_wage_pre Girl NRTI c.NRTI#i.Girl $X $FE , ///
    select(worked = $Z) two
outreg2 using "Table3.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: All ln(daily wages)") 
		
heckman ln_daily_wage_pre NRTI $X $FE if Girl==0, ///
    select(worked = $Z) two
outreg2 using "Table3.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Male ln(daily wages)") 
	
heckman ln_daily_wage_pre NRTI $X $FE if Girl==1, ///
    select(worked = $Z) two
outreg2 using "Table3.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Female ln(daily wages)") 
 
* 16–50 years old
heckman ln_monthly_wage_pre Girl NRTI c.NRTI#i.Girl $X $FE if age >=16 & age <= 50 , ///
    select(worked = $Z) two
outreg2 using "Table3.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: All (16–50 years old)") 	
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==0 & age >=16 & age <= 50, ///
    select(worked = $Z) two
outreg2 using "Table3.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Male (16–50 years old)") 
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==1 & age >=16 & age <= 50, ///
    select(worked = $Z) two
outreg2 using "Table3.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Female (16–50 years old)") 
 
* Excluding self-employed 
heckman ln_monthly_wage_pre Girl NRTI c.NRTI#i.Girl $X $FE if selfemployed == 0 , ///
    select(worked = $Z) two
outreg2 using "Table3.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: All (Excluding self-employed)") 
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==0 & selfemployed == 0, ///
    select(worked = $Z) two
outreg2 using "Table3.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Male (Excluding self-employed)") 
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==1 & selfemployed == 0, ///
    select(worked = $Z) two
outreg2 using "Table3.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Female (Excluding self-employed)") 
 
* Reweighted by urban-rural population composition 
gen byte samp = !missing(worked) ///
    & ur_pop_weight>0 & !missing(ur_pop_weight) ///
    & !(worked==1 & missing(ln_monthly_wage_pre))
probit worked $Z if samp==1 [pweight=ur_pop_weight], vce(robust)
tempvar xb imr
predict double `xb' if e(sample), xb
gen double `imr' = .
replace `imr' = normalden(`xb')/normal(`xb') if worked==1 & e(sample)
replace `imr' = 50 if `imr' > 50 & worked==1 & e(sample)
reg ln_monthly_wage_pre ///
    Girl NRTI c.NRTI#i.Girl $X $FE `imr' ///
    if worked==1 & samp==1 [pweight=ur_pop_weight], vce(robust)
outreg2 using "Table3.xls", excel append ///
    adjr2 se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: All (Reweighted by urban-rural population composition)")		
drop samp 
 
gen byte samp = !missing(worked) ///
    & ur_pop_weight>0 & !missing(ur_pop_weight) ///
    & !(worked==1 & missing(ln_monthly_wage_pre))
probit worked $Z if samp==1 & Girl==0 [pweight=ur_pop_weight], vce(robust)
tempvar xb imr
predict double `xb' if e(sample), xb
gen double `imr' = .
replace `imr' = normalden(`xb')/normal(`xb') if worked==1 & e(sample)
replace `imr' = 50 if `imr' > 50 & worked==1 & e(sample)
reg ln_monthly_wage_pre ///
    NRTI $X $FE `imr' ///
    if worked==1 & samp==1 & Girl==0 [pweight=ur_pop_weight], vce(robust)
outreg2 using "Table3.xls", excel append ///
    adjr2 se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Male (Reweighted by urban-rural population composition)")
drop samp

gen byte samp = !missing(worked) ///
    & ur_pop_weight>0 & !missing(ur_pop_weight) ///
    & !(worked==1 & missing(ln_monthly_wage_pre))
probit worked $Z if samp==1 & Girl==1 [pweight=ur_pop_weight], vce(robust)
tempvar xb imr
predict double `xb' if e(sample), xb
gen double `imr' = .
replace `imr' = normalden(`xb')/normal(`xb') if worked==1 & e(sample)
replace `imr' = 50 if `imr' > 50 & worked==1 & e(sample)
reg ln_monthly_wage_pre ///
    NRTI $X $FE `imr' ///
    if worked==1 & samp==1 & Girl==1 [pweight=ur_pop_weight], vce(robust)
outreg2 using "Table3.xls", excel append ///
    adjr2 se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Female (Reweighted by urban-rural population composition)")
drop samp
 
**************************************************************************
*** Table 4:  Results by age and education groups
**************************************************************************
* Age group
heckman ln_monthly_wage_pre Girl NRTI c.NRTI#i.Girl $X $FE if age >=16 & age <= 39, ///
    select(worked = $Z) two
outreg2 using "Table4.xls", excel replace ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: All Younger cohort (16–39)")  
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==0 & age >=16 & age <= 39, ///
    select(worked = $Z) two
outreg2 using "Table4.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Male Younger cohort (16–39)") 
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==1 & age >=16 & age <= 39, ///
    select(worked = $Z) two
outreg2 using "Table4.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Female Younger cohort (16–39)")  
 
heckman ln_monthly_wage_pre Girl NRTI c.NRTI#i.Girl $X $FE if age >= 40, ///
    select(worked = $Z) two
outreg2 using "Table4.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: All Older cohort (40 and above)")  
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==0 & age >= 40, ///
    select(worked = $Z) two
outreg2 using "Table4.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Male Older cohort (40 and above)") 
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==1 & age >= 40, ///
    select(worked = $Z) two
outreg2 using "Table4.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Female Older cohort (40 and above)")  
  
* Education group
heckman ln_monthly_wage_pre Girl NRTI c.NRTI#i.Girl $X $FE if edu_years < 12, ///
    select(worked = $Z) two
outreg2 using "Table4.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: All Lower educational attainment (<12 years)")  
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==0 & edu_years < 12, ///
    select(worked = $Z) two
outreg2 using "Table4.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Male Lower educational attainment (<12 years)") 
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==1 & edu_years < 12, ///
    select(worked = $Z) two
outreg2 using "Table4.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Female Lower educational attainment (<12 years)")  
 
heckman ln_monthly_wage_pre Girl NRTI c.NRTI#i.Girl $X $FE if edu_years >= 12, ///
    select(worked = $Z) two
outreg2 using "Table4.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: All Higher educational attainment (≥12 years)")  
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==0 & edu_years >= 12, ///
    select(worked = $Z) two
outreg2 using "Table4.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Male Higher educational attainment (≥12 years)") 
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==1 & edu_years >= 12, ///
    select(worked = $Z) two
outreg2 using "Table4.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Female Higher educational attainment (≥12 years)")  
	
**************************************************************************
*** Table 5:  Results by education group among younger cohort
**************************************************************************	
	 
heckman ln_monthly_wage_pre Girl NRTI c.NRTI#i.Girl $X $FE if age >=16 & age <= 39 & edu_years < 12 , ///
    select(worked = $Z) two
outreg2 using "Table5.xls", excel replace ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: All Lower education (<12 years) among Younger cohort")  
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==0 & age >=16 & age <= 39 & edu_years < 12, ///
    select(worked = $Z) two
outreg2 using "Table5.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Male Lower education (<12 years) among Younger cohort") 
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==1 & age >=16 & age <= 39 & edu_years < 12, ///
    select(worked = $Z) two
outreg2 using "Table5.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Female Lower education (<12 years) among Younger cohort")   
 
heckman ln_monthly_wage_pre Girl NRTI c.NRTI#i.Girl $X $FE if age >=16 & age <= 39 & edu_years >= 12 , ///
    select(worked = $Z) two
outreg2 using "Table5.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: All Higher education (≥12 years) among Younger cohort")  
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==0 & age >=16 & age <= 39 & edu_years >= 12, ///
    select(worked = $Z) two
outreg2 using "Table5.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Male Higher education (≥12 years) among Younger cohort") 
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==1 & age >=16 & age <= 39 & edu_years >= 12, ///
    select(worked = $Z) two
outreg2 using "Table5.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Female Higher education (≥12 years) among Younger cohort")   
  
**************************************************************************
*** Table 6:  Results by region based on digital economy development levels
**************************************************************************	 

xtile DEI_tercile = DEI, nq(3)
label define DEI3 1 "Low DEI" 2 "Mid DEI" 3 "High DEI"
 
heckman ln_monthly_wage_pre Girl NRTI c.NRTI#i.Girl $X $FE if DEI_tercile == 1 , ///
    select(worked = $Z) two
outreg2 using "Table6.xls", excel replace ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: All Less developed digital economy")  
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==0 & DEI_tercile == 1, ///
    select(worked = $Z) two
outreg2 using "Table6.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Male Less developed digital economy") 
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==1 & DEI_tercile == 1, ///
    select(worked = $Z) two
outreg2 using "Table6.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Female Less developed digital economy")   
  
heckman ln_monthly_wage_pre Girl NRTI c.NRTI#i.Girl $X $FE if DEI_tercile == 2 , ///
    select(worked = $Z) two
outreg2 using "Table6.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: All Moderately developed digital economy")  
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==0 & DEI_tercile == 2, ///
    select(worked = $Z) two
outreg2 using "Table6.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Male Moderately developed digital economy") 
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==1 & DEI_tercile == 2, ///
    select(worked = $Z) two
outreg2 using "Table6.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Female Moderately developed digital economy")    
 
heckman ln_monthly_wage_pre Girl NRTI c.NRTI#i.Girl $X $FE if DEI_tercile == 3 , ///
    select(worked = $Z) two
outreg2 using "Table6.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: All Highly developed digital economy")  
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==0 & DEI_tercile == 3, ///
    select(worked = $Z) two
outreg2 using "Table6.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Male Highly developed digital economy") 
		
heckman ln_monthly_wage_pre NRTI $X $FE if Girl==1 & DEI_tercile == 3, ///
    select(worked = $Z) two
outreg2 using "Table6.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Heckman: Female Highly developed digital economy")    
  
**************************************************************************
*** Table 7:  Results across wage distribution
**************************************************************************	  

tabulate province, generate(PROVINCE_d)
tabulate year, generate(iyear_d)
gen double NRTI_Girl = NRTI * Girl

arhomme ln_monthly_wage_pre  Girl NRTI NRTI_Girl $X PROVINCE_d1-PROVINCE_d28 iyear1 iyear2 , select(worked = $Z) subsample(1184) tau(4)quantiles(.1)
outreg2 using "Table7.xls", excel replace ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Results across wage distribution 10th")     
	
arhomme ln_monthly_wage_pre  Girl NRTI NRTI_Girl $X PROVINCE_d1-PROVINCE_d28 iyear1 iyear2 , select(worked = $Z) subsample(1184) tau(4)quantiles(.25)
outreg2 using "Table7.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Results across wage distribution 25th")     
		
arhomme ln_monthly_wage_pre  Girl NRTI NRTI_Girl $X PROVINCE_d1-PROVINCE_d28 iyear1 iyear2 , select(worked = $Z) subsample(1184) tau(4)quantiles(.5)
outreg2 using "Table7.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Results across wage distribution 50th")     
		
arhomme ln_monthly_wage_pre  Girl NRTI NRTI_Girl $X PROVINCE_d1-PROVINCE_d28 iyear1 iyear2 , select(worked = $Z) subsample(1184) tau(4)quantiles(.75)
outreg2 using "Table7.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Results across wage distribution 75th")     
		
arhomme ln_monthly_wage_pre  Girl NRTI NRTI_Girl $X PROVINCE_d1-PROVINCE_d28 iyear1 iyear2, select(worked = $Z) subsample(1184) tau(4)quantiles(.9)
outreg2 using "Table7.xls", excel append ///
    se alpha(0.01,0.05,0.10) ///
    symbol(***,**,*) ///
    bdec(3) sdec(3) rdec(3) ///
    ctitle("Results across wage distribution 90th")     

**************************************************************************
*** Table 8:  Decomposition results of mean wage 
**************************************************************************	  
eststo clear
oaxaca ln_monthly_wage_pre NRTI experience edu_years health marry hukou PROVINCE_d1-PROVINCE_d28 iyear1 iyear2 , by(Girl) pooled  
eststo oaxaca1
esttab oaxaca1 using oaxaca.csv, replace ///
    b(%9.3f) se(%9.3f) ///
    label ///
    star(* 0.10 ** 0.05 *** 0.01) ///
    title("Decomposition results of mean wage")

**************************************************************************
*** Table 9:  Decomposition results across wage distribution
**************************************************************************	 
bootstrap _b, reps(1000):  oaxaca_rif ln_monthly_wage_pre NRTI experience edu_years health marry hukou PROVINCE_d1-PROVINCE_d28 iyear1 iyear2, by(Girl)  wgt(1) rif(q(10))  
eststo rif_q10    
bootstrap _b, reps(1000):  oaxaca_rif ln_monthly_wage_pre NRTI experience edu_years health marry hukou PROVINCE_d1-PROVINCE_d28 iyear1 iyear2 , by(Girl)  wgt(1) rif(q(25))   
eststo rif_q25 
bootstrap _b, reps(1000):  oaxaca_rif ln_monthly_wage_pre NRTI experience edu_years health marry hukou PROVINCE_d1-PROVINCE_d28 iyear1 iyear2 , by(Girl)  wgt(1) rif(q(50))    
eststo rif_q50
bootstrap _b, reps(1000):  oaxaca_rif ln_monthly_wage_pre NRTI experience edu_years health marry hukou PROVINCE_d1-PROVINCE_d28 iyear1 iyear2 , by(Girl)  wgt(1) rif(q(75))    
eststo rif_q75
bootstrap _b, reps(1000):  oaxaca_rif ln_monthly_wage_pre NRTI experience edu_years health marry hukou PROVINCE_d1-PROVINCE_d28 iyear1 iyear2 , by(Girl)  wgt(1) rif(q(90))    
eststo rif_q90 
esttab rif_q10 rif_q25 rif_q50 rif_q75 rif_q90 using "oaxaca_table9_rif.csv", replace ///
    b(%9.3f) se(%9.3f) ///
    label ///
    star(* 0.10 ** 0.05 *** 0.01) ///
    title("Decomposition across the wage distribution") ///
    mtitles("q10" "q25" "q50" "q75" "q90")  

**************************************************************************
*** Figure 2: Kernel density of NRTI by gender
**************************************************************************

twoway ///
(kdensity NRTI if Girl==0, bw(0.1) lcolor(blue) lpattern(solid)) ///
(kdensity NRTI if Girl==1, bw(0.1) lcolor(red)  lpattern(solid)) ///
, ///
legend(order(1 "Male" 2 "Female")) ///
title("Kernel Density of Non-routine Task Intensity by Gender") ///
xtitle("Non-routine Task Intensity") ///
ytitle("Density")

graph export "Figure2.eps", as(eps) replace


**************************************************************************
*** Figure 3: Kernel density of wages by gender and by task types (low-NRTI tasks vs. high-NRTI tasks)
**************************************************************************

summarize NRTI, detail
gen NRTI_cat = (NRTI> r(p50))
label define NRTI_lab 0 "Below median" 1 "Above median"
twoway (kdensity ln_monthly_wage_pre if Girl == 0 & NRTI_cat == 0, lcolor(blue) lpattern(solid) legend(label(1 "Male, Low-NRTI"))) /// 
       (kdensity ln_monthly_wage_pre if Girl == 0 & NRTI_cat == 1, lcolor(blue) lpattern(dash) legend(label(2 "Male, High-NRTI"))) /// 
       (kdensity ln_monthly_wage_pre if Girl == 1 & NRTI_cat == 0, lcolor(red) lpattern(solid) legend(label(3 "Female, Low-NRTI"))) /// 
       (kdensity ln_monthly_wage_pre if Girl == 1 & NRTI_cat == 1, lcolor(red) lpattern(dash) legend(label(4 "Female, High-NRTI"))) /// 
       , title("Kernel wage distribution by Gender and Non-routine Task Intensity (Low vs. High NRTI)", size(medsmall)  color(black) justification(center)  margin(0  10 0 0 )) ///
	     xtitle("Ln Monthly Wages") ///
         ytitle("Kernel Density Estimate", placement(left) justification(left) margin(0 4 0 0))
graph export  "Figure3.eps", replace



********************************************************************************
*********************************  THE END *************************************
********************************************************************************




